<?php
/**
 * LowCalVanilla Functions tests
 *
 * @package Extensions
 * @subpackage test
 * @copyright Damien Lebrun 2007
 * @author Damien Lebrun
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GPLv2
 */

//require_once('simpletest/unit_tester.php');
//require_once('simpletest/reporter.php');
require_once(dirname(__File__).'/../src/Functions.php');

/**
 * LowCalVanilla Functions tests
 * @package Extensions
 */
class TestFunctions extends UnitTestCase {

	function testIsGzipIncompatibleClient() {
		unset($_SERVER['HTTP_USER_AGENT']);
		$this->assertFalse(IsGzipIncompatibleClient(true, false));
		$this->assertTrue(IsGzipIncompatibleClient(true, true));

		$Firefox2 = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6';
		$IE7 = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; Alexa Toolbar)';
		$Opera9 = 'Opera/9.00 (Windows NT 5.1; U; en)';
		$Safari2 = 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko) Safari/417.8';
		$Safari3 = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; bg) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1';
		$IE6 = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
		$IE55 = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)';


		$_SERVER['HTTP_USER_AGENT'] = $Firefox2;
		$this->assertFalse(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $IE7;
		$this->assertFalse(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $Opera9;
		$this->assertFalse(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $Safari2;
		$this->assertFalse(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $Safari3;
		$this->assertFalse(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $IE55;
		$this->assertFalse(IsGzipIncompatibleClient(false));

		$_SERVER['HTTP_USER_AGENT'] = $IE55;
		$this->assertTrue(IsGzipIncompatibleClient());
		$_SERVER['HTTP_USER_AGENT'] = $IE6;
		$this->assertTrue(IsGzipIncompatibleClient());
	}
}